
Ext.define('DCApp.model.Image', {
    extend: 'DCApp.model.BaseEntity',
    fields: [
        {name: 'objNo'},
        {name: 'objName'},
        {name: 'imageName'},
        {name: 'imageEngname'},
        {name: 'imageJapname'},
        {name: 'imgType'},
        {name: 'imgColor'},
        {name: 'cdlabel'},
        {name: 'imgFile'},
        {name: 'cdNo'},
        {name: 'photographer'},
        {name: 'provider'},
        {name: 'registerMan'},
		{name: 'usage'},
        {name: 'registerTime', type: 'date',  dateFormat: 'n/j h:ia'},
        {name: 'regCReceiver'},
        {name: 'regCTime', type: 'date',  dateFormat: 'n/j h:ia'},
        {name: 'scanSuffix'},
        {name: 'scanReceiver'},
        {name: 'scanCTime', type: 'date',  dateFormat: 'n/j h:ia'},
        {name: 'suffix'},
        {name: 'handler'},
        {name: 'handleTime', type: 'date',  dateFormat: 'n/j h:ia'},
        {name: 'handleCTime', type: 'date',  dateFormat: 'n/j h:ia'},
        {name: 'haveSmall', type: 'int'},
        {name: 'haveBigimage', type: 'int'},
        {name: 'isLivepicture'},
        {name: 'confirmMan'},
        {name: 'confirmTime', type: 'date',  dateFormat: 'n/j h:ia'},
        {name: 'confirmFlag'},
        {name: 'returnReceiver'},
        {name: 'returnTime', type: 'date',  dateFormat: 'n/j h:ia'},
        {name: 'mimgWidth', type: 'int'},
        {name: 'mimgHeight', type: 'int'},
        {name: 'keywords'},
        {name: 'description'},
        {name: 'ispart', type: 'int'},
        {name: 'ggrsimage', type: 'int'},
        {name: 'note'},
        {name: 'descriptionUk'},
        {name: 'pathSmall'},
        {name: 'pathMiddle'},
        {name: 'imageSource'},
        {
        	name:'b_hide_img',
        	calculate: function (data) {
                var imgId = data.id;
                if(imgId<DCApp.Cfg.ID_START ||
                		(data.cdlabel && data.cdlabel.indexOf('Y')!=0)){
                	return false;
                }
                return true;
        	}
        },
        {
            name: 'uri_img',
            calculate: function (data) {
                var cdlabel = data.cdlabel;
                var imgf = data.imgFile;
                if(!cdlabel || !imgf || cdlabel.indexOf('Y')==0)
                	return null;
                var pos = imgf.lastIndexOf('.');
                if(pos!=-1)
                	imgf = imgf.substring(0,pos);
               return DCApp.Cfg.WEB_ROOT_IMG 
                	+ cdlabel.replace(/\./g,'/')
                	+ '/'+imgf+'.jpg';
            }
        },
        {
            name: 'uri_m',
            calculate: function (data) {
                var path = data.pathMiddle;
                var cdlabel = data.cdlabel;
                var imgf = data.imgFile;
                var imgId = data.id;
                //sim data
                var pid = data['id'];
                if(!path || !pid)
              	  return '';
                if(path.indexOf('path')==0){
              	  return '../imgs/'+pid % 5+'.jpg';
                }
                //本系统上传
                if(path){
            	  path = path.replace(/\\/g,'/');
              	  var uri = '/fileopen?_dc='+new Date().getTime()+'&fp=/'+path; 
              	  return uri;
              	  //老网站影像利用导入
                }else{
                	if(!cdlabel)
                		return false;
                if(imgId<DCApp.Cfg.ID_START){
            		return DCApp.Cfg.WEB_ROOT_CC
            			+'files/image/'
            			+cdlabel.replace(/\./g,'/')
    			  		+'/'+imgf+'[400PX].jpg';
                }else{
                var pos = imgf.lastIndexOf('.');
                if(pos!=-1)
                	imgf = imgf.substring(0,pos);
            	  var uri = DCApp.Cfg.WEB_ROOT_IMG 
                	+ cdlabel.replace(/\./g,'/')
                	+ '/'+imgf+'[2048].jpg'; 
              	  return uri;
                }
            }
            }
        },{

            name: 'uri',
            calculate: function (data) {
                var path = data.pathMiddle;
                var cdlabel = data.cdlabel;
                var imgf = data.imgFile;
                var imgId = data.id;

                //sim data
                var pid = data['id'];
                if(!path || !pid)
              	  return '';
                if(path.indexOf('path')==0){
              	  return '../imgs/'+pid % 5+'.jpg';
                }
                //本系统上传
                if(path){
            	  path = path.replace(/\\/g,'/');
              	  var uri = '/fileopen?_dc='+new Date().getTime()+'&size=90&fp=/'+path; 
              	  return uri;
              	  //老网站影像利用导入
                }else{
                	if(!cdlabel)
                		return false;
                	if(imgId<DCApp.Cfg.ID_START){
            		return DCApp.Cfg.WEB_ROOT_CC
            			+'files/image/'
            			+cdlabel.replace(/\./g,'/')
    			  		+'/'+imgf+'[126PX].jpg';
                }else{
                var pos = imgf.lastIndexOf('.');
                if(pos!=-1)
                	imgf = imgf.substring(0,pos);
            	  var uri = DCApp.Cfg.WEB_ROOT_IMG 
                	+ cdlabel.replace(/\./g,'/')
                	+ '/'+imgf+'[126].jpg'; 
              	  return uri;
                }
               }
            }
                
        }
    ],
    rmap:{
		'imageSource':['影像利用','影像局部','外来影像'],
		'imgType':['照片' ,'电子文档','扫描'],
		'imgColor':['彩色' ,'黑白']
        //,'isLivepicture':[0,1]
	},
	manyToMany:['CcPay']


});
